﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace SchoolOA.Controllers
{
    public class CWCController : Controller
    {
        public IActionResult Index()
        {
            string name = HttpContext.Session.GetString("username");
            string section = HttpContext.Session.GetString("section");
            if (name == null || !section.Equals("cwc"))
            {
                return Redirect(Url.Action("ErrorPage", "Home"));
            }
            return View();
        }

        public IActionResult SectionWage()
        {
            string name = HttpContext.Session.GetString("username");
            string section = HttpContext.Session.GetString("section");
            if (name == null || !section.Equals("cwc"))
            {
                return Redirect(Url.Action("ErrorPage", "Home"));
            }
            return View();
        }

        public IActionResult EditWage(string teacherid, string time)
        {
            string name = HttpContext.Session.GetString("username");
            string section = HttpContext.Session.GetString("section");
            if (name == null || !section.Equals("cwc"))
            {
                return Redirect(Url.Action("ErrorPage", "Home"));
            }
            ViewData["teacherid"] = teacherid;
            ViewData["time"] = time;
            return View();
        }


        public IActionResult MaterialTable()
        {
            string name = HttpContext.Session.GetString("username");
            string section = HttpContext.Session.GetString("section");
            if (name == null || !section.Equals("cwc"))
            {
                return Redirect(Url.Action("ErrorPage", "Home"));
            }
            return View();
        }

        public IActionResult MaterialDetail(int id)
        {
            string name = HttpContext.Session.GetString("username");
            string section = HttpContext.Session.GetString("section");
            if (name == null || !section.Equals("cwc"))
            {
                return Redirect(Url.Action("ErrorPage", "Home"));
            }
            ViewData["id"] = id;
            return View();
        }
    }
}